package com.dcl.spride;

import java.util.HashMap;
import java.util.Iterator;

public class Application {

	WhoseIp whoseip = null;
	WhoseData whosedata = null;
	HashMap<String, String> map = new HashMap<String, String>();

	Application() {
		Bean bean = new Bean();
		IpInfo ipinfo = new IpInfo();
		Info info = new Info();
		ipinfo.setBean(bean);
		info.setBean(bean);
		whoseip = new WhoseIp();
		whosedata = new WhoseData();
		whoseip.setIpinfo(ipinfo);
		whosedata.setInfo(info);
		whoseip.setMap();
		whosedata.setMap();
		HashMap<String, String> ipmap = whoseip.getMap();
		HashMap<String, String> datamap = whosedata.getMap();

		
		if (ipmap.size() != 0 && datamap.size() != 0) {
			Iterator<String> dataiterator = datamap.keySet().iterator();
			while (dataiterator.hasNext()) {
				String ipkey = dataiterator.next();
				String hostname = ipmap.get(ipkey);
				String peerinfo = datamap.get(ipkey);
				if(hostname==null||"".equals(hostname)){
					hostname=ipkey;
				}
				map.put(hostname, peerinfo);
			}
		}
	}

	public WhoseIp getWhoseip() {
		return whoseip;
	}

	public WhoseData getWhosedata() {
		return whosedata;
	}

	public HashMap<String, String> getMap() {
		return map;
	}

	public static void main(String[] args) {
		Application application = new Application();
		HashMap<String, String> map = application.getMap();
		Iterator<String> iterator = map.keySet().iterator();
		while (iterator.hasNext()) {
			String key = iterator.next();
			String value = map.get(key);
		}

	}

}
